﻿using System;
using Extensibility;
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.CommandBars;
using System.Resources;
using System.Reflection;
using System.Globalization;
using System.IO;
using VSLangProj;


namespace PlainConcepts.Fx.Dnie.AddIn
{
    class DniUtils
    {
        static string ss = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        static string path = Path.Combine( ss, "Visual Studio 2008\\Addins\\" );
        
        static string dllname1 = "PlainConcepts.Fx.Dnie.dll";
        static string dllname2 = "PlainConcepts.SmartCard.dll";
        public static void addDniReference(Project currentProj)
        {
            VSProject vsProj = currentProj.Object as VSProject;

            if (vsProj != null)
            {
                if (Directory.Exists(path))
                {
                    try
                    {
                        foreach (Reference r in vsProj.References)
                            if (r.Name + ".dll" == dllname1)
                                return;
                        vsProj.References.Add(path + dllname1);
                    }
                    catch (DirectoryNotFoundException ex)
                    {
                        //MessageBox.Show(ex.Message);
                    }
                }

            }
        }

        public static void addUnMannagedReference(Project currentProj)
        {
            if (Directory.Exists(Path.GetDirectoryName(currentProj.FullName) + "\\bin\\debug"))
            {
                File.Copy(path + dllname2, Path.GetDirectoryName(currentProj.FullName) + "\\bin\\debug\\" + dllname2, true);
            }
        }
        
    }
}
